package com.itheima.singleinstance;

public class A {

    //用静态变量来保存唯一实例
    private static A instance;

    //私有化构造器：确保单例类对外不能创建太多对象。
    private A() {
    }

    public static A getInstance() {
        if (instance == null) {
            instance = new A();
        }
        return instance;
    }
}
